<template>
  <div>
    <div class="message-item" v-for="item in list" :key="item.id">
      <div class="profile-photo">
        <van-image width="50" height="50" radius="8" :src="item.photo" />
      </div>
      <div class="contents">
        <div class="top">
          <div class="name">{{ item.name }}</div>
          <div class="time">{{ item.item }}</div>
        </div>
        <div class="message">
          {{ item.content }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "MessageItem",
  props: {
    list: {
      type: [],
      default: [],
    },
  },
};
</script>

<style lang="less" scoped>
.message-item {
  margin: 12px;
  display: flex;
  align-items: center;

  .profile-photo {
    margin-right: 8px;
    font-size: 0;
  }

  .contents {
    height: 50px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .top {
      width: 100%;
      display: flex;
      justify-content: space-between;

      .name {
        font-size: 16px;
        font-weight: 600;
      }

      .time {
        font-size: 12px;
        color: #646566;
      }
    }

    .message {
      width: 180px;
      font-size: 14px;
      color: #646566;
      overflow: hidden;
      text-overflow: ellipsis; /* 多出部分以省略号形式隐藏 */
      white-space: nowrap; /* 禁止换行  normal可以换行 */
    }
  }
}
</style>
